package one.bugu.android.demon.util;

import android.view.View;

public abstract class OnViewClickListener implements View.OnClickListener {

    private final long INTERVAL_TIME = 1000L;

    private long beforeTime = 0L;

    @Override
    public void onClick(View view) {
        if (view != null) {
            long curTime = System.currentTimeMillis();
            if(curTime - beforeTime >= INTERVAL_TIME){
                //本次点击时间与上一次点击时间差大于规定时间差可以响应点击事件
                singleClick(view);
                beforeTime = curTime;
            }
        }
    }

    /**
     * 按钮不可重复点击
     *
     * @param view
     */
    protected abstract void singleClick(View view);

}
